import Vue from 'vue'
import Vuex from 'vuex'
import theme from './modules/theme'
import user from './modules/user'
import route from './modules/route'
import tagsView from './modules/tagsView'
import getters from './getters'
import dict from "./modules/dict"
Vue.use(Vuex)

const store = new Vuex.Store({
    modules: {
        theme,
        route,
        user,
        tagsView,
        dict
    },
    getters,
    state:{
        recordId:undefined,
        apiType:undefined
    },
    mutations: {
        SET_RECORD_ID(state, id){
            state.recordId = id;
        },
        SET_API_TYPE(state, type){
            state.apiType = type;
        },
    },
    actions:{
        getRecordId({commit},v){
            commit('SET_RECORD_ID', v)
        },
        getApiType({commit},v){
            commit('SET_API_TYPE', v)
        },
    },
})

export default store

// export default new Vuex.Store({
//     state: {
//         user: null,
//
//     },
//     mutations: {},
//     actions: {
//         // 存储登录状态
//         login({state}, user) {
//             state.user = user
//             window.localStorage.setItem('user', JSON.stringify(user))
//             window.localStorage.setItem('token', user.token)
//         },
//         // 初始化用户信息
//         initUser({state}) {
//             let user = window.localStorage.getItem('user')
//             state.user = user ? JSON.parse(user) : null
//         },
//         // 清除登录状态
//         logout({state}) {
//             state.user = null
//             window.localStorage.removeItem('user')
//             window.localStorage.removeItem('token')
//         }
//     },
//     modules: {}
// })
